import { useState, useEffect, useMemo, useCallback } from "react";
export const useCutDown = () => {
  let [time, setTime] = useState(0);
  const analysis = () => {
    return fixedZero(time);
  };
  function fixedZero(val: number) {
    return val * 1 < 10 ? `0${val}` : val;
  }
  const cutdown = useMemo(() => analysis(), [time]);
  useEffect(() => {
    let timer = setInterval(() => {
      setTime(++time);
    }, 1000);
    return () => {
      clearInterval(timer);
    };
  }, []);
};
